<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var students = [
        { id: 1, name: "xiaoqiang", age: "18", score: 90 },
        { id: 2, name: "xiaoqiang", age: "19", score: 50 },
        { id: 3, name: "xiaoqiang", age: "29", score: 40 },
        { id: 4, name: "xiaoqiang", age: "34", score: 60 },
        { id: 5, name: "xiaoqiang", age: "24", score: 80 },
      ];
      let a = +prompt("请输入您的id");
      // 例如：输入的是 id 是 3， 输出的信息应该是 {id: 3, name: 'xiaoqiang', age: '29', score: 40}
      for (let i = 0; i < students.length; i++) {
        if (students[i].id === a) {
          console.log(students[i]);
        }
      }
    </script>
  </body>
</html>
